import { Injectable } from '@angular/core';

@Injectable()
export class LoggerService {

    logs: string[] = [];
    premsg = '';
    preMsgCount = 1;

    // 打印消息数据
    logMeesage(message: string) {
      if (message === this.premsg) {
        this.logs[this.logs.length - 1] = message + `(${this.preMsgCount += 1}条消息)`;
      } else {
        // 新的消息
        this.premsg = message;
        this.preMsgCount += 1;
        this.logs.push(message);
      }
    }
    // 清除消息
     clearnMessage() {
      this.logs = [];
     }
}
